<?php

namespace App\Constants;

/**
 * 考勤状态枚举
 * 定义各种考勤状态和结果
 */
class AttendanceStatusEnum extends AbstractEnum
{
    // 考勤状态常量
    public const ON_TIME = 'on_time';
    public const LATE = 'late';
    public const EARLY_LEAVE = 'early_leave';
    public const ABSENT = 'absent';
    public const LEAVE = 'leave';
    public const BUSINESS_TRIP = 'business_trip';
    public const OVERTIME = 'overtime';
    public const NOT_CHECKED = 'not_checked';
    public const EXCEPTION = 'exception';

    /**
     * 获取所有枚举实例
     */
    public static function getAll(): array
    {
        return [
            new self('on_time', '正常', '按时到岗', '#28A745', 'check-circle', 1),
            new self('late', '迟到', '上班迟到', '#DC3545', 'exclamation-triangle', 2),
            new self('early_leave', '早退', '提前下班', '#FD7E14', 'sign-out-alt', 3),
            new self('absent', '缺勤', '未到岗', '#DC3545', 'times-circle', 4),
            new self('leave', '请假', '正常请假', '#17A2B8', 'calendar-minus', 5),
            new self('business_trip', '出差', '出差在外', '#6C757D', 'plane', 6),
            new self('overtime', '加班', '加班工作', '#FFC107', 'clock', 7),
            new self('not_checked', '未打卡', '忘记打卡', '#E83E8C', 'question-circle', 8),
            new self('exception', '异常', '考勤异常', '#6F42C1', 'exclamation-circle', 9),
        ];
    }

    /**
     * 获取正常状态
     */
    public static function getNormalStatuses(): array
    {
        return [
            self::ON_TIME,
            self::LEAVE,
            self::BUSINESS_TRIP,
            self::OVERTIME,
        ];
    }

    /**
     * 获取异常状态
     */
    public static function getAbnormalStatuses(): array
    {
        return [
            self::LATE,
            self::EARLY_LEAVE,
            self::ABSENT,
            self::NOT_CHECKED,
            self::EXCEPTION,
        ];
    }

    /**
     * 检查是否为正常状态
     */
    public static function isNormalStatus(string $status): bool
    {
        return in_array($status, self::getNormalStatuses());
    }

    /**
     * 检查是否为异常状态
     */
    public static function isAbnormalStatus(string $status): bool
    {
        return in_array($status, self::getAbnormalStatuses());
    }
}
